FROM node:16.16.0-slim AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci

FROM deps AS build
COPY . .
RUN npm run build

FROM build AS users
CMD [ "node", "./dist/apps/users/src/main.js" ]

FROM build AS bot
CMD [ "node", "./dist/apps/bot/src/main.js" ]

FROM build AS search
CMD [ "node", "./dist/apps/search/src/main.js" ]

FROM build AS resources
CMD [ "node", "./dist/apps/resources/src/main.js" ]

FROM build AS cdn
CMD [ "node", "./dist/apps/cdn/src/main.js" ]

FROM build AS migrator
CMD [ "node", "./dist/apps/migrator/src/main.js" ]

FROM golang:1.19 AS deps
WORKDIR /app
RUN apt update && apt install make

FROM deps AS gobuilder
COPY . .
RUN make build-go

FROM gobuilder AS notifications
CMD [ "./bin/notifications-service" ]